Fix unix-ffi/re: Fix OverflowError in re.groups().#1089
Merged
dpgeorge merged 2 commits intomicropython:masterfrom Mar 19, 2026
Merged
Fix unix-ffi/re: Fix OverflowError in re.groups().#1089dpgeorge merged 2 commits intomicropython:masterfrom
dpgeorge merged 2 commits intomicropython:masterfrom
Conversation
Member
|
Thanks for this, the fix looks good! Can I suggest adding more tests, ie: m = re.match(r"(.)?", "")
assert m.group() == ""
assert m.group(0, 1) == ("", None)
assert m.groups() == (None,)
assert m.groups("default") == ("default",)That will test |
Contributor
Author
|
Sure, happy to add. I noticed that the readme mentions 'unsupported' for the unix-ffi folder, and I do not think these modules are included in CI testing either. So AFIKT the tests need to be run manually, so still useful for validating. |
Member
I think it is run under CI, see |
Member
|
@Josverl are you able to add those few tests I list above? |
Contributor
Author
|
sorry , got sidetracked. |
Adjust the re.groups() methods to properly handle the PCRE2_UNSET value for unmatched optional groups. This change prevents OverflowError when calling groups() on a match with no content. The return matches CPython's. Fixes: micropython/micropython#18877 Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
69312ff to
47fec41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adjust the
re.groups()methods to properly handle thePCRE2_UNSETvalue for unmatched optional groups.This change prevents
OverflowErrorwhen callinggroups()on a match with no content.The return matches CPython's.
A test case for an empty string match has been added to verify expected behavior.
Fixes micropython/micropython#18877